home *** CD-ROM | disk | FTP | other *** search
- Path: fohnix.metronet.com!not-for-mail
- From: milam@fohnix.metronet.com (Stan Milam)
- Newsgroups: comp.lang.c
- Subject: Re: Convert String to Int?
- Date: 6 Mar 1996 15:31:11 -0600
- Organization: Texas Metronet, Inc (login info (214/488-2590 - 817/571-0400))
- Message-ID: <4hl06v$rp8@fohnix.metronet.com>
- References: <4hf3sk$k57@hustle.rahul.net> <4hh5c9$iia@nadine.teleport.com>
- NNTP-Posting-Host: fohnix.metronet.com
- X-Newsreader: TIN [version 1.2 PL2]
-
- GHouck (hksys@teleport.com) wrote:
- : Stephen Parry <sparry@rahul.net> wrote:
- : >I have some numbers, range 0 to 999, stored as a strings. I need to
- : >convert them to integers. Could I get some hints how to do this?
- : >
- : >Stephen
- : Stephen,
- : One way is to use the function 'atoi()'; i.e., intVal = atoi( strVal );
- : Yours, Geoff Houck
-
- You can also use strtol() and cast the result to whatever integer type
- you are working with. I remember reading an article once, I think by
- P.J. Plauger, which stated strtol() was prefered over atoi() and atou(), and
- atol().
-
- Regards,
- Stan Milam.
-